<#assign ctx=springMacroRequestContext.contextPath />
<#include "/macro/publicMacro.ftl">
<#import "/macro/pagination.ftl" as Pagination>

<@header title="群组列表">
    <link href="${ctx}/resource/common/css/pagination.css" rel="stylesheet">
    <link href="${ctx}/resource/frame/datetimepicker/jquery.datetimepicker.min.css" rel="stylesheet">
</@header>

<@body>
    <h2 class="module-title">群组管理</h2>

    <div class="alert alert-primary" role="alert">
        <form class="form-inline form-margin" action="${ctx}/imGroup/list">
            <div class="form-group mb-2">
                <label for="name" class="ml-2">群名称：</label>
                <input type="text" class="form-control" id="name" name="name" value="${imGroup.name}">
            </div>
            <div class="form-group mb-2">
                <label for="ownerId" class="ml-2">群主：</label>
                <input type="text" class="form-control" id="ownerId" name="ownerId" value="${imGroup.ownerId}">

            </div>
            <div class="form-group mb-2">
                <label for="enable" class="ml-2">是否可用：</label>
                <select class="form-control" name="enable" id="enable">
                    <option value="">请选择</option>
                    <#list statusValues as status>
                        <option value="${status}" <#if status == imGroup.status>selected</#if>>${status.desc}</option>
                    </#list>
                </select>
            </div>
            <div class="form-group mb-2">
                <label for="tenantId" class="ml-2">租户：</label>
                <select class="form-control" name="tenantId" id="tenantId">
                    <#list tenants as tenant>
                        <option value="${tenant.id}" <#if tenant.id == imGroup.tenantId>selected</#if>>${tenant.description}</option>
                    </#list>
                </select>
            </div>

            <div class="form-group mx-sm-3 mb-2">
                <button type="submit" class="btn btn-primary">查询</button>
            </div>

            
            <div class="form-group mx-sm-3 mb-2" style="float:right">
                <span style="float:left"><a href="${ctx}/imGroup/toAdd">添加数据</a></span>
            </div>
            
        </form>
    </div>

    <div class="table-responsive">
        <table class="table table-striped table-bordered">
            <thead>
                <th>主键</th>
                <th>群名称</th>
                <th>群主</th>
                <th>是否可用</th>
                <th>租户id</th>
                <th>创建时间</th>
                <th>更新时间</th>
                <th>操作</th>
            </thead>
            <tbody>
            <#list imGroups.beans as imGroup>
                <tr>
                    <td>${imGroup.id!}</td>
                    <td>${imGroup.name!}</td>
                    <td>${imGroup.ownerId!}</td>
                    <td>
                        <#if imGroup.enable == 'enable'><h5><span class="badge badge-success">${imGroup.enable.desc!}</span></h5></#if>
                        <#if imGroup.enable == 'disable'><h5><span class="badge badge-secondary">${imGroup.enable.desc!}</span></h5></#if>
                    </td>
                    <td>${imGroup.tenantId!}</td>
                    <td>${(imGroup.createTime?string('yyyy-MM-dd hh:mm:ss'))!} </td>
                    <td>${(imGroup.updateTime?string('yyyy-MM-dd hh:mm:ss'))!} </td>
                    <td><a class="btn btn-primary btn-sm" href="${ctx}/imGroup/view/${imGroup.id?c}" role="button" aria-pressed="true">详情</a>
                        <a class="btn btn-info btn-sm" href="${ctx}/imGroup/toEdit/${imGroup.id?c}" role="button" aria-pressed="true">编辑</a>
                    </td>
                </tr>
            </#list>
            </tbody>
        </table>

        <@Pagination.pagination formId="imGroupForm"
            pageNo=imGroups.pageNo
            pageTotal=imGroups.pageTotal
            total=imGroups.total
            pageSize=imGroups.pageSize
            action="${ctx}/imGroup/list">
        </@Pagination.pagination>
    </div>
</@body>

<@footer>
    <script src="${ctx}/resource/frame/datetimepicker/jquery.datetimepicker.full.min.js"></script>

    <script type="text/javascript">
        $(function () {
                $('#startCreateTime').datetimepicker({
                    format:'Y-m-d H:i:s',
                    lang:'zh'});
                $('#endCreateTime').datetimepicker({
                    format:'Y-m-d H:i:s',
                    lang:'zh'});
                $('#startUpdateTime').datetimepicker({
                    format:'Y-m-d H:i:s',
                    lang:'zh'});
                $('#endUpdateTime').datetimepicker({
                    format:'Y-m-d H:i:s',
                    lang:'zh'});
        });
    </script>

    <script src="${ctx}/resource/common/js/pagination.js"></script>
    <script src="${ctx}/resource/common/js/jquery.validate.min.js"></script>
</@footer>